<template>
	<view>
		<view class="mainpadding_top ffffff ">
			<view class="flexbetween pdl">
				<view class="xiaohei main_size">开票类型</view>
				<view class="flexright">
					<u-radio-group v-model="opentype" placement="row" circle style="flex: 0;">
						<u-radio activeColor="#c1282e" :customStyle="{marginRight: '30rpx'}" label="普票"
							name="1"></u-radio>
						<u-radio activeColor="#c1282e" label="专票" name="2"></u-radio>
					</u-radio-group>
				</view>
			</view>
			<view class="flexbetween pdl margin-top">
				<view class="xiaohei main_size">发票名称</view>
				<input type="text" class="xiaohei textright main_size" placeholder="请输入发票名称" v-model="fp_name" />
			</view>
			<view class="flexbetween pdl margin-top">
				<view class="xiaohei main_size">税号</view>
				<input type="text" class="xiaohei textright main_size" placeholder="请输入税号" v-model="fp_rh" />
			</view>
			<view class="flexbetween pdl margin-top">
				<view class="xiaohei main_size">单位地址</view>
				<input type="text" class="xiaohei textright main_size" placeholder="请输入单位地址" v-model="fp_address" />
			</view>
			<view class="flexbetween pdl margin-top">
				<view class="xiaohei main_size">电话号码</view>
				<input type="number" class="xiaohei textright main_size" placeholder="请输入电话号码" v-model="fp_tel" />
			</view>
			<view class="flexbetween pdl margin-top">
				<view class="xiaohei main_size">开户银行</view>
				<input type="text" class="xiaohei textright main_size" placeholder="请输入开户银行" v-model="fp_bank" />
			</view>
			<view class="flexbetween pdl margin-top">
				<view class="xiaohei main_size">银行账号</view>
				<input type="text" class="xiaohei textright main_size" placeholder="请输入银行账号" v-model="fp_bankno" />
			</view>
		</view>
		<view class="posibottom mainpadding">
			<view class="submitbtn" @click="submit">确定</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				opentype: "1",
				fp_name: "",
				fp_rh: "",
				fp_address: "",
				fp_tel: "",
				fp_bank: "",
				fp_bankno: "",
				listid: ""
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.getindex()
		},
		methods: {
			getindex() {
				httpRequest.request('/api/user/getUerInfo', 'GET', {}).then(res => {
					let data = res.data
					this.opentype = data.opentype?data.opentype.toString():"1"
					this.fp_name = data.fp_name?data.fp_name:""
					this.fp_rh = data.fp_rh?data.fp_rh:""
					this.fp_address = data.fp_address?data.fp_address:""
					this.fp_tel = data.fp_tel?data.fp_tel:""
					this.fp_bank = data.fp_bank?data.fp_bank:""
					this.fp_bankno = data.fp_bankno?data.fp_bankno:""
				})
			},
			submit() {
				if (this.fp_name == "") {
					httpRequest.toast("请输入发票名称")
					return false
				}
				if (this.fp_rh == "") {
					httpRequest.toast("请输入税号")
					return false
				}
				if (this.fp_address == "") {
					httpRequest.toast("请输入单位地址")
					return false
				}
				if (this.fp_tel == "") {
					httpRequest.toast("请输入电话号码")
					return false
				}
				if (this.fp_bank == "") {
					httpRequest.toast("请输入开户银行")
					return false
				}
				if (this.fp_bankno == "") {
					httpRequest.toast("请输入银行账号")
					return false
				}
				httpRequest.request('/api/Yjnbmoneycl/openFp', 'GET', {
					id: this.listid,
					opentype: this.opentype,
					fp_name: this.fp_name,
					fp_rh: this.fp_rh,
					fp_address: this.fp_address,
					fp_tel: this.fp_tel,
					fp_bank: this.fp_bank,
					fp_bankno: this.fp_bankno,
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>